<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div>div</div>
<p>p</p>
<div>div</div>
<span>span</span>
<p>p</p>
<div>div</div>

<script>
    function select(selector){
        return document.querySelectorAll(selector);
    }
    function each( arr,callback){
        for(var i=0;i<arr.length;i++){
            callback(arr[i],i)
        }
    }


    var nodes = select('div,p');
    each(nodes,function(v){
        v.style.border = v.nodeName == 'DIV'
        ?'1px solid red'
                :'1px solid blue'
    })
</script>
</body>
</html>